/**
 * Main application routes
 */

'use strict';

var errors = require('./components/errors');

module.exports = function (app) {
    app.route('/setCookie').get(require('./api/controller/common/common_controller').setCookie);
    app.route('/clearCookie').get(require('./api/controller/common/common_controller').clearCookie);

    // Insert routes below
    app.use('/api', require('./api/controller/common'));
    app.use('/api/ask', require('./api/controller/ask'));
    app.use('/api/dialog', require('./api/controller/dialog'));

    // All undefined asset or api routes should return a 404
    app.route('/:url(api|auth|components|app|bower_components|assets)/*').get(errors[404]);

    // text styles style.html
    app.route('/styles').get(function (req, res) {
        res.sendFile(app.get('appPath') + '/styles.html');
    });

    // All other routes should redirect to the index.html
    app.route('/*').get(function (req, res) {
        res.sendFile(app.get('appPath') + '/index.html');
    });
};
